﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.Reporting.WinForms;

namespace SGLL
{
    public partial class FormPrintPreview : SGLL.FormTemplate
    {
        //Global Variables
        private DateTime _date;
        private string _route;
        private string _openByUser;
        private string _closeByUser;
        private bool _sample;
        private bool _shipping;
        private bool _result;
        private bool _vials;
        private bool _promotional;
        private bool _prices;
        private bool _visit;
        private byte _typeOfSamples;
        private string _departament;
        private ReportDataSource reportDataSource = new ReportDataSource();
        //Constructor
        /// <summary>
        /// Print preview of the report
        /// </summary>
        /// <param name="date">Date</param>
        /// <param name="route">Route</param>
        /// <param name="openByUser">Open By User</param>
        /// <param name="closeByUser">Close By User</param>
        /// <param name="typeOfSamples">Types Of Samples</param>
        /// <param name="departament">Departament</param>
        public FormPrintPreview(DateTime date, string route, string openByUser, string closeByUser, byte typeOfSamples, string departament)
        {
            _date = date;
            _route = route;
            _openByUser = openByUser;
            _closeByUser = closeByUser;
            _typeOfSamples = typeOfSamples;
            _departament = departament;
            InitializeComponent();
            //Initialize Report
            this.tableAdapterComplaints.Fill
            (
                this.dataSetComplaints.PROCEDURE_COMPLAINTS_CONSULTATION,
                _date,
                _route,
                _typeOfSamples,
                _openByUser,
                _closeByUser,
                _departament
            );
            reportDataSource.Name = "DataSetComplaints";
            reportDataSource.Value = this.bindingSourceComplaints;
            this.reportViewer.LocalReport.DataSources.Add(reportDataSource);
            this.reportViewer.LocalReport.ReportEmbeddedResource = "SGLL.ReportComplaints.rdlc";
        }
        /// <summary>
        /// Print preview of the report
        /// </summary>
        /// <param name="date">Date</param>
        /// <param name="route">Route</param>
        /// <param name="openByUser">Open By User</param>
        /// <param name="closeByUser">Close By User</param>
        /// <param name="sample">Sample</param>
        /// <param name="shipping">Shipping</param>
        /// <param name="result">Result</param>
        /// <param name="vials">Vials</param>
        /// <param name="promotional">Promotional</param>
        /// <param name="prices">Prices</param>
        /// <param name="visit">Visit</param>
        public FormPrintPreview(DateTime date, string route, string openByUser, string closeByUser, bool sample, bool shipping, bool result, bool vials, bool promotional, bool prices, bool visit)
        {
            _date = date;
            _route = route;
            _openByUser = openByUser;
            _closeByUser = closeByUser;
            _sample = sample;
            _shipping = shipping;
            _result = result;
            _vials = vials;
            _promotional = promotional;
            _prices = prices;
            _visit = visit;
            InitializeComponent();
            //Initialize Report
            tableAdapterCalls.Fill(
                    dataSetCalls.PROCEDURE_CALLS_CONSULTATION,
                    _date,
                    _route,
                    _openByUser,
                    _closeByUser,
                    _sample,
                    _shipping,
                    _result,
                    _vials,
                    _promotional,
                    _prices,
                    _visit
                );
            reportDataSource.Name = "DataSetCalls";
            reportDataSource.Value = this.bindingSourceCalls;
            this.reportViewer.LocalReport.DataSources.Add(reportDataSource);
            this.reportViewer.LocalReport.ReportEmbeddedResource = "SGLL.ReportCalls.rdlc";
        }
        //Form
        private void FormPrintPreview_Load(object sender, EventArgs e)
        {
            toolStripButtonPrint.Enabled = true;
            ReportParameter parameter = new ReportParameter("ReportParameterDate", _date.ToShortDateString(), false);
            reportViewer.LocalReport.SetParameters(parameter);
            reportViewer.SetDisplayMode(DisplayMode.PrintLayout);
            reportViewer.RefreshReport();
        }
        //Tool Strip Buttons
        protected override void toolStripButtonPrint_Click(object sender, EventArgs e)
        {
            reportViewer.PrintDialog();
        }
        protected override void toolStripButtonClear_Click(object sender, EventArgs e)
        {
            reportViewer.RefreshReport();
        }
    }
}